package sudroid.android;

import android.content.ContentResolver;
import android.content.Context;
import android.database.Cursor;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;

public final class NetworkUtil
{
  static final Uri PREFERRED_APN_URI = Uri.parse("content://telephony/carriers/preferapn");
  private static NetworkUtil instance;
  static APNWrapper wrapper;
  private ConnectivityManager mConnectivityManager;
  private ContentResolver mContentResolver;
  private Context mContext;

  private NetworkUtil(Context paramContext)
  {
    Context localContext = paramContext.getApplicationContext();
    this.mContext = localContext;
  }

  /** @deprecated */
  public static NetworkUtil getInstance(Context paramContext)
  {
    monitorenter;
    try
    {
      if (instance == null)
        instance = new NetworkUtil(paramContext);
      NetworkUtil localNetworkUtil = instance;
      monitorexit;
      return localNetworkUtil;
    }
    finally
    {
      localObject = finally;
      monitorexit;
    }
    throw localObject;
  }

  public APNWrapper getAPN()
  {
    if (this.mContentResolver == null)
    {
      ContentResolver localContentResolver1 = this.mContext.getContentResolver();
      this.mContentResolver = localContentResolver1;
    }
    ContentResolver localContentResolver2 = this.mContentResolver;
    Uri localUri = PREFERRED_APN_URI;
    String[] arrayOfString1 = new String[4];
    arrayOfString1[0] = "name";
    arrayOfString1[1] = "apn";
    arrayOfString1[2] = "proxy";
    arrayOfString1[3] = "port";
    String[] arrayOfString2 = null;
    String str1 = null;
    Cursor localCursor = localContentResolver2.query(localUri, arrayOfString1, null, arrayOfString2, str1);
    boolean bool = localCursor.moveToFirst();
    if (localCursor.isAfterLast())
    {
      localAPNWrapper1 = null;
      return localAPNWrapper1;
    }
    if (wrapper == null)
      wrapper = new APNWrapper();
    APNWrapper localAPNWrapper1 = wrapper;
    if (localCursor.getString(0) == null)
    {
      str2 = null;
      label139: localAPNWrapper1.name = str2;
      localAPNWrapper1 = wrapper;
      if (localCursor.getString(1) != null)
        break label244;
      str2 = null;
      label165: localAPNWrapper1.apn = str2;
      localAPNWrapper1 = wrapper;
      if (localCursor.getString(2) != null)
        break label260;
    }
    label260: for (String str2 = null; ; str2 = localCursor.getString(2).trim())
    {
      localAPNWrapper1.proxy = str2;
      APNWrapper localAPNWrapper2 = wrapper;
      int i = localCursor.getInt(3);
      localAPNWrapper2.port = i;
      localAPNWrapper1 = wrapper;
      break;
      str2 = localCursor.getString(0).trim();
      break label139;
      label244: str2 = localCursor.getString(1).trim();
      break label165;
    }
  }

  public NetworkState getNetworkState()
  {
    if (this.mConnectivityManager == null)
    {
      ConnectivityManager localConnectivityManager = (ConnectivityManager)this.mContext.getSystemService("connectivity");
      this.mConnectivityManager = localConnectivityManager;
    }
    NetworkInfo localNetworkInfo = this.mConnectivityManager.getActiveNetworkInfo();
    NetworkState localNetworkState;
    if ((localNetworkInfo == null) || (!localNetworkInfo.isAvailable()))
      localNetworkState = NetworkState.NOTHING;
    while (true)
    {
      return localNetworkState;
      if (localNetworkInfo.getType() == 0)
      {
        localNetworkState = NetworkState.MOBILE;
        continue;
      }
      localNetworkState = NetworkState.WIFI;
    }
  }

  public class APNWrapper
  {
    String apn;
    String name;
    int port;
    String proxy;

    public String getApn()
    {
      return this.apn;
    }

    public String getName()
    {
      return this.name;
    }

    public int getPort()
    {
      return this.port;
    }

    public String getProxy()
    {
      return this.proxy;
    }
  }

  public enum NetworkState
  {
    static
    {
      MOBILE = new NetworkState("MOBILE", 1);
      WIFI = new NetworkState("WIFI", 2);
      NetworkState[] arrayOfNetworkState = new NetworkState[3];
      NetworkState localNetworkState1 = NOTHING;
      arrayOfNetworkState[0] = localNetworkState1;
      NetworkState localNetworkState2 = MOBILE;
      arrayOfNetworkState[1] = localNetworkState2;
      NetworkState localNetworkState3 = WIFI;
      arrayOfNetworkState[2] = localNetworkState3;
      ENUM$VALUES = arrayOfNetworkState;
    }
  }
}

/* Location:           D:\Program Files\eclipse\apktool-r01-3\新浪微博\classes.dex.dex2jar.jar
 * Qualified Name:     sudroid.android.NetworkUtil
 * JD-Core Version:    0.6.0
 */